<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //继承
        function Dad(name,age){
            this.name = name
            this.age = age
            this.money = "100000"
        }

        Dad.prototype.fn= function(){
            console.log("fn")
        }

        function Son(name,age){
            Dad.call(this,name,age)
            this.sex = "男"
        }

        Son.prototype = Dad.prototype
        Son.prototype.fn = function(){
            console.log('重写的fn')
        }
        let zhangsan = new Son("张三",20)
        console.log(zhangsan.money)
        console.log(zhangsan.sex)
        zhangsan.fn()
        let zhangyi = new Dad("张一",30)
        zhangyi.fn()
    </script>
</body>
</html>